import {ribbon,dispatcher} from './ribbon';
import React, {useEffect,useContext} from "react";
import { AppContext } from "../../reHook/start";

export default function App () {
    const {ab,dispatch} = useContext(AppContext)
    if (typeof (window.ribbon) == "undefined") {
        window.ribbon = ribbon;
    }
    if(typeof (window.dispatcher) == "undefined") {
        window.dispatcher = dispatcher;
    }
    const setCookie = (key, value, path, domain, day) => {
		value = JSON.stringify(value);
		let expires = '',
			setPath,
			setdomain;
		if (day) {
			let d = new Date();
			d.setDate(d.getDate() + day);
			expires = '; expires=' + d.toUTCString();
		}
		if (path) {
			setPath = `; path=${path}`;
		} else {
			setPath = '; path=/nccloud';
		}
		if (domain) {
			setdomain = `; setdomain=${domain}`;
			document.cookie = key + '=' + value + expires + setPath + setdomain;
		} else {
			document.cookie = key + '=' + value + expires + setPath;
        }
        if(key === 'cookiets'){
            window.cookiets = value
        }
	};
    useEffect(()=>{
        let cckk = (window.cookiets) || Date.now()
        setCookie('cookiets', cckk);
        // if (typeof (window.ribbon) == "undefined") {
        //     window.ribbon = ribbon;
        // }
        // if(typeof (window.dispatcher) == "undefined") {
        //     window.dispatcher = dispatcher;
        // }
        // window.ribbon = ribbon;
        // window.dispatcher = dispatcher
        // setTimeout(() => {
            
        // }, 500);
        console.log(window.location.href)
        // document.cookie = "cookiets=1611558572163; path=/; httponly;";
    // document.cookie=cookieName+ "=" +encodeURIComponent(value)+ "; expires="+ expiresTime+ "; path="+path; 
    },[])
    const link = window.location.origin + '/nccloud'
    return (
        <div className="tree-area">
            {/* <iframe src = {link} >
            </iframe> */}
            {/* window.location.href = "http://127.0.0.1:3006/nccloud" */}
            this is main container
        </div>
    )
}
// export default class App extends Component {
//     constructor(props){
//         super(props);
//         this.state = {

//         };
//         window.ribbon = ribbon;
//         window.dispatcher = dispatcher
//         console.log('初次加载',props)
//     }
//     render(){
//         return (
//             <div className="tree-area">
//                 this is main container
//             </div>
//         )
    
//     }
// }


